<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>正则扩展-dotAll模式</title>
</head>
<body>
<script>
    str = `
    <nav>
    <ul>
        <li>
            <a href="#">学习</a>
            <p>日期: 2023-1-1</p>
        </li>
        <li>
            <a href="#">游戏</a>
            <p>日期: 2023-10-10</p>
        </li>
    </ul>
</nav>`
    // dot -- . (dot ==> .  元字符  除换行符以外的任意单个字符)
    // 正则
    const reg = /<li>.*?<a href="#">(.*?)<\/a>.*?<p>(.*?)<\/p>/gs  // g -- 全局匹配、s -- 换行
    let result
    let data=[]
    while (result=reg.exec(str)){
        data.push({name: result[1],time:result[2]})
    }
    console.log(data[0],data[1])
</script>
</body>
</html>